package com.biz.primus.ms.commodity.api;

import com.biz.primus.commodity.vo.backend.*;
import com.biz.primus.common.vo.SpringPageVO;
import com.biz.primus.ms.commodity.service.backend.VendorProductService;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("soa/platformProductService")
public class PlatformVendorProductApiController {

    private final VendorProductService vendorProductService;

    public PlatformVendorProductApiController(VendorProductService vendorProductService) {
        this.vendorProductService = vendorProductService;
    }

    @ApiOperation("创建商品(商家端创建商品产生商品审核记录供平台端审核)")
    @PostMapping("createProduct")
    public CreateProductAuditVo createProduct(@RequestBody CreateProductAuditVo reqVo) {
        return vendorProductService.createAuditProduct(reqVo);
    }

    @ApiOperation("商家更新商品(商家端更新商品产生的审核记录也要供平台端审核)")
    @PostMapping("updateAuditProduct")
    public void updateAuditProduct(@RequestBody UpdateProductAuditVo reqVo) {
        vendorProductService.updateAuditProduct(reqVo);
    }

    @ApiOperation("商家商品列表")
    @PostMapping("listVendorProducts")
    public SpringPageVO<VendorProductListItemVo> listVendorProducts(@RequestBody VendorProductListReqVo reqVo) {
        return vendorProductService.listVendorProducts(reqVo);
    }

    @ApiOperation("获取商家商品数据")
    @GetMapping("vendorProductDetail")
    public VendorProductDetailVo vendorProductDetail(@RequestParam("vendorId") Long vendorId, @RequestParam("productId") Long productId) {
        return vendorProductService.getVendorProductDetail(vendorId, productId);
    }

    @ApiOperation("获取商家商品审核详情")
    @GetMapping("vendorProductAuditDetail")
    public VendorProductAuditDetailVo getVendorProductAuditDetail(@RequestParam("vendorId") Long vendorId,@RequestParam("productId") Long productId) {
        return vendorProductService.getVendorProductAuditDetail(vendorId, productId);
    }

    @ApiOperation("A类商品下架")
    @PostMapping("soldOutProduct")
    public void soldOutProduct(@RequestBody SoldOutProductVo soldOutProductVo){
        vendorProductService.soldOutProduct(soldOutProductVo);
    }

    @ApiOperation("商家端后台获取关联商品信息")
    @PostMapping("relevanceProduct")
    public RelevanceProductVo relevanceProduct(@RequestBody SearchRelevanceProductVo reqVo){
        return vendorProductService.getRelevanceProduct(reqVo);
    }

    @ApiOperation("商家创建或更新关联商品信息")
    @PostMapping("createOrUpdateRelevanceProductList")
    public RelevanceProductListVo createOrUpdateRelevanceProductList(@RequestBody RelevanceProductListVo reqVo){
//        return vendorProductService.createOrUpdateRelevanceProductList(reqVo);
        return null;
    }

    @ApiOperation("获取商家关联商品列表")
    @PostMapping("listVendorRelevanceProduct")
    public SpringPageVO<ListRelevanceProductVo> listVendorRelevanceProduct(@RequestBody ListVendorRelevanceProductReqVo reqVo){
        return vendorProductService.listVendorRelevanceProduct(reqVo);
    }

    @ApiOperation("搜索获得商品列表信息")
    @PostMapping("getVendorProductList")
    public SpringPageVO<ProductBriefVo> getVendorProductList(@RequestBody BackendProductListReqVo reqVo){
        return vendorProductService.getVendorProductList(reqVo);
    }

    @ApiOperation("根据商品编码集合 获取商品图片名称信息")
    @PostMapping("getProductLogoList")
    public List<ProductLogoVo> getProductLogoList(@RequestBody ProductLogoReqVo reqVo){
        return vendorProductService.getProductLogoList(reqVo);
    }





}
